home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Deutsche Edition 1
/
Deutsche Edition 1.iso
/
amok
/
amok_lha
/
amok69.lha
/
PatternLibrary
/
pgrep.doc
< prev
next >
Wrap
Text File
|
1993-08-15
|
5KB
|
127 lines
NAME
pgrep - search a file for a pattern or string
VERSION
pgrep V0.4
SYNOPSIS
pgrep [-<flags>...] <pattern> [<file>...]
DESCRIPTION
pgrep is a small grep command. If one or more files are specified, it
will search in these files for lines matching a pattern. If no files
are given, it will use the standard input for its searching operation.
Normally, each line found is copied to the standard output. pgrep
supports standard Amiga pattern.
If <pattern> does not contain any pattern characters, the fast Boyer-
Moore string searching algorithm will be used.
Sorry, it might take some time, if you use a real pattern instead, but
the average case works fast! And don't worry if you can't understand
why some pattern will be found very fast and others won't. I really
can understand this ;-) So in most cases the pattern
"(f#o|bar|f#obar)" will take much more time to be found than e.g.
"foobar#(f#o|bar)foobar". I hope to fix this in future.
pgrep might return one of the following values, which can be checked
within a running script:
0 - A match was found
5 - No match was found
10 - An error was detected
Please note that the following things, that will cause a
string to be written to standard error, are only warnings and
won't return value 10 since pgrep will continue nevertheless.
This happens
- if a specified file was not found
- if a specified switch is unknown
Options
-c Only a count of matching lines is printed.
-i Ignore uppercase/lowercase distinctions during comparisons
-l Only the names of files with matching lines are listed (once),
seperated by new-lines. This will reset option c.
-n Each line is preceded by its relative line number starting at 1.
This option is ignored if -c, -l or -q is specified. The
linecounter will be increased when ' ' or new-line is found. Note
that some editors create more newlines.
-q (Quiet) Do not write anything to the standard output regardless
of matching lines. Overwrites any option that would produce
output. Note that error messages are written to stderr.
-s Error messages are suppressed
-v All lines but those matching are printed
-x Matches are recognized only when the entire input line matches
the pattern.
Notes
- You have to quote pattern characters if you want to search for
strings that contain those characters. Otherwise if you e.g. enter
"pgrep foo*bar" all lines that match with "#?foo#?bar#?" will be
printed. So simply use "foo'*bar" as a search pattern.
- If you want to search for a pattern that begins with a "-", you
could type "%-..." which is exactely the same since "%" is an empty
string. Otherwise your pattern will be treated as some options.
- pgrep will increase it's linecounter after each linefeed (0x0A) or
nullbyte (0x00). TurboText is able to count the lines in the same
way, but I think CED isn't, so CED will begin a new line behind
e.g. ^L, which seams to cause errors in linenumbers when pgrepping
e.g. pattern.doc. So be careful if you're using binary files and
option -n.
- If a line takes more than about 1KB, pgrep will wrap it internally.
If there's a match within the wrap, it won't be found!
EXAMPLES
1> pgrep pattern pgrep.doc
Will grep all lines of the file pgrep.doc that contain the string
"pattern".
1> pgrep -v pattern <pgrep.doc
Will grep all lines of stdin (here: pgrep.doc), that do not
contain the string "pattern".
1> pgrep -vi pattern <pgrep.doc
Same as above, but case-insensitive.
1> pgrep -c pa#tern pgrep.doc pattern.doc
Will print the number of lines of the files pgrep.doc and
pattern.doc, that contain the pattern "pa#tern".
1> pgrep -n -x # pa#tern.library/* pattern.doc
Will print all lines of the file pattern.doc, that match exactely
with the pattern "# pa#tern.library/*". The linenumber of each
matching line will be displayed.
TODO
- Option to display the bytesoffset of a match with a pattern.
- Use of SearchPattern() as soon as pattern.library supports this
function...
AUTHOR
This Freeware was written by Angela Schmidt, Neu-Ulm, Germany.
EMail: Angela@rz.uni-karlsruhe.de
For further details please refer to Pattern.Doc.